package com.eatme.web.security.authentication.wechat.applet.service.impl;

import com.eatme.web.app.customer.entity.TbUser;
import com.eatme.web.security.authentication.dao.SecurityUserAuthDao;
import com.eatme.web.security.authentication.domain.entity.SecurityUserAuth;
import com.eatme.web.security.authentication.wechat.applet.dao.WechatAppletSecurityUserDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Optional;

@Service("wechatAppletSecurityUserServiceImpl")
@Transactional
public class WechatAppletSecurityUserServiceImpl {
    private static final Logger LOG = LoggerFactory.getLogger(WechatAppletSecurityUserServiceImpl.class);

    public final WechatAppletSecurityUserDao wechatAppletSecurityUserDao;

    public final SecurityUserAuthDao securityUserAuthDao;

    public WechatAppletSecurityUserServiceImpl(WechatAppletSecurityUserDao wechatAppletSecurityUserDao, SecurityUserAuthDao securityUserAuthDao) {
        this.wechatAppletSecurityUserDao = wechatAppletSecurityUserDao;
        this.securityUserAuthDao = securityUserAuthDao;
    }

    public SecurityUserAuth findByOpenId(String openid) {
        Optional<SecurityUserAuth> securityUserAuth = securityUserAuthDao.findSecurityUserAuthByIdentifier(openid);
        return securityUserAuth.get();
    }

}
